package com.zhuo.project.order.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhuo.framework.aspectj.lang.annotation.Log;
import com.zhuo.framework.aspectj.lang.enums.BusinessType;
import com.zhuo.project.order.domain.ZzDiagnoseOptLog;
import com.zhuo.project.order.service.IZzDiagnoseOptLogService;
import com.zhuo.framework.web.controller.BaseController;
import com.zhuo.framework.web.domain.AjaxResult;
import com.zhuo.common.utils.poi.ExcelUtil;
import com.zhuo.framework.web.page.TableDataInfo;

/**
 * 处方单操作历史Controller
 * 
 * @author zhuo
 * @date 2020-03-26
 */
@RestController
@RequestMapping("/order/log")
public class ZzDiagnoseOptLogController extends BaseController
{
    @Autowired
    private IZzDiagnoseOptLogService zzDiagnoseOptLogService;

    /**
     * 查询处方单操作历史列表
     */
    @PreAuthorize("@ss.hasPermi('order:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZzDiagnoseOptLog zzDiagnoseOptLog)
    {
        startPage();
        List<ZzDiagnoseOptLog> list = zzDiagnoseOptLogService.selectZzDiagnoseOptLogList(zzDiagnoseOptLog);
        return getDataTable(list);
    }

    /**
     * 导出处方单操作历史列表
     */
    @PreAuthorize("@ss.hasPermi('order:log:export')")
    @Log(title = "处方单操作历史", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ZzDiagnoseOptLog zzDiagnoseOptLog)
    {
        List<ZzDiagnoseOptLog> list = zzDiagnoseOptLogService.selectZzDiagnoseOptLogList(zzDiagnoseOptLog);
        ExcelUtil<ZzDiagnoseOptLog> util = new ExcelUtil<ZzDiagnoseOptLog>(ZzDiagnoseOptLog.class);
        return util.exportExcel(list, "log");
    }

    /**
     * 获取处方单操作历史详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(zzDiagnoseOptLogService.selectZzDiagnoseOptLogById(id));
    }

    /**
     * 新增处方单操作历史
     */
    @PreAuthorize("@ss.hasPermi('order:log:add')")
    @Log(title = "处方单操作历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZzDiagnoseOptLog zzDiagnoseOptLog)
    {
        return toAjax(zzDiagnoseOptLogService.insertZzDiagnoseOptLog(zzDiagnoseOptLog));
    }

    /**
     * 修改处方单操作历史
     */
    @PreAuthorize("@ss.hasPermi('order:log:edit')")
    @Log(title = "处方单操作历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZzDiagnoseOptLog zzDiagnoseOptLog)
    {
        return toAjax(zzDiagnoseOptLogService.updateZzDiagnoseOptLog(zzDiagnoseOptLog));
    }

    /**
     * 删除处方单操作历史
     */
    @PreAuthorize("@ss.hasPermi('order:log:remove')")
    @Log(title = "处方单操作历史", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zzDiagnoseOptLogService.deleteZzDiagnoseOptLogByIds(ids));
    }
}
